from django.db import models


# Create your models here.
class Publisher(models.Model):
    id = models.AutoField(verbose_name='出版社id',primary_key=True)
    name = models.CharField(verbose_name='出版社名字',max_length=64, null=False)
    address = models.CharField(verbose_name='出版社地址',max_length=64, null=False)


class Book(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(verbose_name='图书名字',max_length=32, null=False)
    price = models.DecimalField(verbose_name='图书价格',max_digits=5, decimal_places=2)
    inventory = models.IntegerField(verbose_name="库存数", null=False)
    sale_num = models.IntegerField(verbose_name="卖出数", null=False)
    publisher = models.ForeignKey(to='Publisher', on_delete=models.CASCADE)
